<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>登陆</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<script type="text/javascript" src="<c:url value='/js/jquery-1.7.1.js'/>"></script>
	<script type="text/javascript">
		$(document).ready(function(){
			$("#btn").click(function(){
				var userName=$("#userName").val();
				var passWord=$("#passWord").val();
				$.post("<%=path %>/user/login",{'userName':userName,'passWord':passWord},function(data){
					console.log(data);
					if(data.message == 'success'){
						window.location.href="<%=path%>/user/getAllUser";
					}else{
						alert("用户名或密码错误！");
					}
				});
				return false;
			});
		})
	</script>
  </head>
  
  <body>
  	<h2>登陆</h2>
    <form id="myform" action="" method="post">
    	<table>
    		<tr>
    			<td>用户名:</td>
    			<td><input id="userName" type="text" name="userName" value="admin"></td>
    		</tr>
    		<tr>
    			<td>密码:</td>
    			<td><input id="passWord" type="passWord" name="passWord" value="123456"></td>
    		</tr>
    		<tr>
    			<td colspan="2"><input id="btn" type="submit" value="提交"></td>
    		</tr>
    	</table>
    </form>
  </body>
</html>
